package com.sultan.guante.userSystem.dao.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;

import com.sultan.guante.userSystem.dao.BaseDAO;
import com.sultan.guante.userSystem.domain.BaseObject;

public abstract class BaseDAOImpl<T,PK extends Serializable> implements BaseDAO<T,PK> {

	
	@Autowired
	private HibernateTemplate hibernateTemplate;
	
	@Override
	public Boolean delete(T entity) {
		  this.hibernateTemplate.delete(entity);
	  
		return true;
	}

	@Override	
	public T save(T entity) {
		    this.hibernateTemplate.saveOrUpdate(entity);
		return entity;
	}

	
	@Override
	public T get(PK id) {
		// TODO Auto-generated method stub
    return hibernateTemplate.get(getRelatedEntityClass(), id);
	}

	@Override
	public List<T> getAll() {
		return hibernateTemplate.loadAll(getRelatedEntityClass());
	}


	



	
	
}
